// pages/channel/invitation/invitation.js
// 引入 QCloud 小程序增强 SDK
var qcloud = require('../../../vendor/qcloud-weapp-client-sdk/index');

// 引入配置
var config = require('../../../config');

// 显示繁忙提示
var showBusy = text => wx.showToast({
    title: text,
    icon: 'loading',
    duration: 10000
});

// 显示成功提示
var showSuccess = text => {
    wx.hideToast();
    wx.showToast({
        title: text,
        icon: 'success'
    });
};

// 显示失败提示
var showModel = (title, content) => {
    wx.hideToast();

    wx.showModal({
        title,
        content: JSON.stringify(content),
        showCancel: false
    });
};

function   formatDate(now)   {     
    var   year=now.getFullYear();     
    var   month=now.getMonth()+1;  
    if(month<10){
        month='0'+month.toString();
    }   
    var   date=now.getDate();
    if(date<10){
        date='0'+date.toString();
    }    
    var   hour=now.getHours(); 
    if(hour<10){
        hour='0'+hour.toString();
    }        
    var   minute=now.getMinutes();
    if(minute<10){
        minute='0'+minute.toString();
    }      
    var   second=now.getSeconds();     
    return   month+"-"+date+" "+hour+":"+minute;     
}


//获取应用实例
var app = getApp()
Page({
  data: {
    "hash_key":"",
    "imageSrc":"",
    "height":"",
    "share_txt":"",
    "share":false,
    "is_qun":false,
    "expire_time":"",
    "text":""
  },
  onLoad: function (e) {
    console.log('onLoad');
    app.getUserInfo(function(userInfo){
      console.log(userInfo);
    });
    this.setData({
        hash_key:e.hash_key
    })
    var self=this
    try {
        var res = wx.getSystemInfoSync();
        self.setData({
            height:(res.windowWidth)*0.8
        });
    } catch (e) {
    // Do something when catch error
    }
  },
  onShow: function () {
    console.log('onShow');
  },
  edit:function(){
    wx.switchTab({
        url: '/pages/person/index/index'
    })
  },
  share:function(){
    this.setData({
        share:true
    })
    var self=this
    setTimeout(function(){
        self.setData({
            share:false
        })
    }, 500);
  },
  onShareAppMessage: function () {
    return {
      title: '密件-邀请您成为我的密友',
      path: 'pages/channel/index/index?hash_key='+this.data.hash_key
    }
  }
})
